﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Text;
using System.Configuration;
using WebApi.Class;
namespace WebApi.Models
{
    public class ShopInfoModel
    {
        public int shopId;
        public string openid = string.Empty;
        public string session_key = string.Empty;
        public string shopName = string.Empty;
        public string contactTel = string.Empty;
        public string address = string.Empty;
        public double longitude;
        public double latitude;
        public string shopDetails = string.Empty;
        public string shopAdvImg = string.Empty;
        public string shopSummary = string.Empty;
        public string shopStartTime = string.Empty;
        public string shopEndTime = string.Empty;
        public string shopFrontCover = string.Empty;
        public int isFristLogin;
        public int isFavorites = 0;//是否收藏

        public static ShopInfoModel GetUserInfo(DataRow dr,bool isSetOpenid)
        {
            ShopInfoModel userinfo = new ShopInfoModel();
            userinfo.shopId = Convert.ToInt32(dr["suid"]);
            userinfo.shopName = Convert.ToString(dr["shopName"]);
            userinfo.contactTel = Convert.ToString(dr["contactTel"]);
            userinfo.longitude = Convert.ToDouble(dr["longitude"]);
            userinfo.latitude = Convert.ToDouble(dr["latitude"]);
            userinfo.address = Convert.ToString(dr["address"]);
            userinfo.shopDetails = Convert.ToString(dr["shopDetails"]);
            userinfo.shopSummary = Convert.ToString(dr["shopSummary"]);
            userinfo.shopStartTime = Convert.ToString(dr["shopStartTime"]);
            userinfo.shopEndTime = Convert.ToString(dr["shopEndTime"]);
            if (!StringUtils.getIsEmpty(dr["shopFrontCover"].ToString())) {
                userinfo.shopFrontCover = ConfigurationSettings.AppSettings["house_url"].ToString() + Convert.ToString(dr["shopFrontCover"]);
            }
            
            //string[] avdArray = Convert.ToString(dr["shopAdvImg"]).Split(',');
            //StringBuilder newshopAdvImg = new StringBuilder();
            //for (int i = 0; i < avdArray.Length; i++) {
            //    newshopAdvImg.Append(ConfigurationSettings.AppSettings["house_url"].ToString()+avdArray[i]+",");
            ////}
            //newshopAdvImg = newshopAdvImg.Remove(newshopAdvImg.Length - 1, 1); //移除掉","
            //userinfo.shopAdvImg = newshopAdvImg.ToString();
            return userinfo;
        }
    }
}